<template>
    <TitleImgCard :title="'房态图'" @onMore="()=>{}" :img="card.img" v-if="isShow" v-btnPermi="{ permi: props.permi, noReport: true, isHiden: true, hideList: props.hideList }" @click="goDetail(props.permi)">
    </TitleImgCard>
</template>

<script setup>
import TitleImgCard from '@/DbComponents/titleImgCard'
import dashBoardApi from '@/api/Manage/Business/dashBoard'
import { ref, reactive, watch, computed } from 'vue'
import { reportLog } from '@/utils/reportLog'
import { useRouter } from 'vue-router'
const router = useRouter()
const props = defineProps({
    permi: {
        type: String,
        required: false,
        default: ''
    },
    hideList: {
        type: Array,
        required: false,
    },
    biProjectCode: {
        type: String,
        required: false,
        default: ''
    },
    updateDate: {
        type: String,
        required: false,
        default: ''
    }
})
const card = reactive(
    {
        img: ''
    }
)

let isShow = ref(false)
const getData = () => {
    dashBoardApi.roomRackisShowApi({ biProjectCode: props.biProjectCode }).then((res) => {
        if (res.data.code == 200) {
            isShow.value = res.data.data.isShow == 1 ? true : false
            card.img = res.data.data.imageAddress
        }
    }).catch(err => {
        console.log(err)
    });
}

const goDetail = (permi) => {
    reportLog({
        type: 4,
        resourceKey: permi,
    })
    const random = Math.random().toString(36).slice(2);
    const token = JSON.parse(localStorage.getItem('authToken')).access_token
    const baseUrl = process.env.VUE_APP_BI_MAP
    console.log(baseUrl)
    router.push({
        path: '/page/routeController/index',
        query: {
            rid: 'page_dashboard_pc_iframe',
            rTitle: '房态图',
            iframeUrl: encodeURIComponent(`https:${baseUrl}/hopsonbi/?isChange=true&random=${random}&biProjectCode=${props.biProjectCode}&updateDate=${props.updateDate}&token=${token}`)
            // iframeUrl: encodeURIComponent(`http://localhost:8000/?isChange=true&random=${random}&biProjectCode=${props.biProjectCode}&updateDate=${props.updateDate}&token=${token}`)
        }
    })
}

getData()

const biProjectCode = computed(() => {
    return props.biProjectCode
});
watch(biProjectCode, () => {
    getData()
}, { deep: true });
</script>

<style scoped lang="scss"></style>
